Witchcraft! Php [migrated]

Posted by Steve Green on Programmers See other posts from Programmers or by Steve Green
Published on 2013-08-02T11:49:56Z Indexed on 2013/08/02 16:02 UTC
Read the original article Hit count: 267

Filed under:
|

This is madness, hoping someone can explain.

$dir = getcwd();  

$a = "/bla/httpdocs/ble";
$b = "/bla/httpdocs/meh";

if( ($dir == $a) || ($dir == $b) ){
$dirlist = glob("../images2/spinner/*.jpg");
}else{
$dirlist = glob("images2/spinner/*.jpg");
}

works fine but

$dir = getcwd();  

if( ($dir == "/bla/httpdocs/ble") || ($dir == "/bla/httpdocs/meh") ){
$dirlist = glob("../images2/spinner/*.jpg");
}else{
$dirlist = glob("images2/spinner/*.jpg");
}

doesn't. (By doesn't work I mean it returns false, I also tried === )

Wondered if strings were being null terminated so tried:

print_r(str_split($a));  //$a has been set to the string below for this.
print_r(str_split("/bla/httpdocs/ble"));

they returned identical arrays

Array ( [0] => / [1] => b [2] => l [3] => a [4] => / [5] => h [6] => t [7] => t [8] => p [9] => d [10] => o [11] => c [12] => s [13] => / [14] => b [15] => l [16] => e ) 
Array ( [0] => / [1] => b [2] => l [3] => a [4] => / [5] => h [6] => t [7] => t [8] => p [9] => d [10] => o [11] => c [12] => s [13] => / [14] => b [15] => l [16] => e )

Anyone?

© Programmers or respective owner

Related posts about php

Related posts about strings